I have implemented the Mersenne Twister in a C++ class that is fast, convenient, portable, and free. Take a look at the class or download the complete package in zip or tarball format. The latest version, v0.8, corrects the list of included headers.
Features:
MTRand r;
double a = r();
/dev/urandom
or time()
and clock()
On my system, a Pentium III running Linux at 500 MHz, the performance test gives the following results for generation of random integers:
MersenneTwister.h | 17.8 million per second |
Original C version | 10.8 million per second |
Cokus's optimized C version | 11.8 million per second |
Standard rand() | 5.8 million per second |
![]() |
Rick Wagner ( rjwagner@writeme.com ) 24 Mar 02 |